#include "StdAfx.h"
#include ".\pvpinfo.h"
#include ".\PVPFormula.h"
#include <Global.h>


PVPInfo::PVPInfo(Player * pPlayer):
m_pPlayer(pPlayer)
{
	SetPVPState( ePVP_USER_NONE );
}

PVPInfo::~PVPInfo(void)
{
}

VOID PVPInfo::Init()
{
	Clear();
	SetPVPState( ePVP_USER_NONE );
	SetTeam( 0 );
	StopTimer();
}

DWORD PVPInfo::CalcPoint()
{
	BASE_PLAYERINFO * pInfo = m_pPlayer->SCPlayer::GetCharInfo();

	pInfo->m_dwPVPMaxSeries = BOUND_CHECK( 0, m_MaxSeries, INT_MAX );
	pInfo->m_dwPVPMaxKill	= BOUND_CHECK( 0, m_TotalKill, INT_MAX );
	pInfo->m_dwPVPMaxDie	= BOUND_CHECK( 0, m_TotalDie, INT_MAX );

	pInfo->m_dwPVPTotalKill	= BOUND_CHECK( 0, pInfo->m_dwPVPTotalKill+m_TotalKill, INT_MAX );
	pInfo->m_dwPVPTotalDie	= BOUND_CHECK( 0, pInfo->m_dwPVPTotalDie+m_TotalDie, INT_MAX );

	DWORD plusPoint = CalcPVPPoint( m_MaxSeries, m_TotalKill, m_TotalDie );

	pInfo->m_dwPVPPoint	= BOUND_CHECK( 0, pInfo->m_dwPVPPoint+plusPoint, INT_MAX );
	return plusPoint;
}

DWORD PVPInfo::CalcScore( LEVELTYPE MyLV, LEVELTYPE OtherLV )
{
	BASE_PLAYERINFO * pInfo = m_pPlayer->SCPlayer::GetCharInfo();
	DWORD plusScore = CalcPVPScore( MyLV, OtherLV - MyLV );
	pInfo->m_dwPVPScore	= BOUND_CHECK( 0, pInfo->m_dwPVPScore+plusScore, INT_MAX );
	return plusScore;
}